package cn.edu.java.io.reader;

import java.io.StringReader;
import java.io.IOException;
import java.io.Reader;

public class StringReaderDemo {
    public static void main(String[] args) {
        String text = "Hello, World!";

        try (Reader reader = new StringReader(text)) {

            int data;
            // 读取字符流，直到达到末尾
            while ((data = reader.read()) != -1) {
                char character = (char) data;
                System.out.print(character);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

